﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class smtp_list : System.Web.UI.Page
{
    MSSQLHelp.SqlDbHelper _sqlhelp = new MSSQLHelp.SqlDbHelper();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            GET_SMTP("2");
    }

    private void GET_SMTP(string page)
    {
        string sql = @"SELECT * FROM ( SELECT Top 5 * FROM ( SELECT Top ( " + page + " * 5 - 1) * FROM dbo.SMTP Order by id desc) t1 ) t2 Order by id asc";
        DataSet ds = _sqlhelp.ExecuteDataSet(sql, CommandType.Text, null);
        DataList_SMTP.DataSource = ds;
        DataList_SMTP.DataBind();
    }
    protected void DataList_SMTP_ItemCommand(object source, DataListCommandEventArgs e)
    {

        Label lb_page = (Label)(e.Item.FindControl("Lb_page"));
        string page = (int.Parse(lb_page.Text) + 1).ToString();
        if (e.CommandName == "Previous")
        {
            GET_SMTP(page);
        }
    }
}